package com.activities.api.data.server;

import java.util.Collection;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.activities.api.data.entities.Group;
import com.activities.api.data.providers.GroupStore;
import com.google.inject.Inject;

@Path("/groupservice")
public class GroupServiceImpl extends ServiceImpl<Group> implements GroupService {
	@Inject
	private GroupStore store;

	public GroupStore getStore() {
		return store;
	}

	public void setStore(GroupStore store) {
		this.store = store;
	}

	@GET
	@Path("/groups/{id}")
	@Produces("application/xml")
	@Override
	public Group get(@PathParam("id") String id) {
		GroupStore store = getStore();
		
		return store.get(id);
	}

	@GET
	@Path("/groups/")
	@Produces("application/xml")
	@Override
	public Collection<Group> getAll() {
		GroupStore store = getStore();
		
		return store.getAll();
	}

	@POST
	@Path("/groups/")
	@Consumes("application/xml")
	@Override
	public void save(Group group) {
		GroupStore store = getStore();
		
		store.save(group);
	}

	@DELETE
	@Path("/groups/{id}")
	@Override
	public void delete(@PathParam("id") String id) {
		GroupStore store = getStore();
		
		store.delete(id);
	}

}
